<template>
    <NavBar title="我的" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-button @click="del" type="primary" size="large">退出登录</van-button>
</template>

<script setup lang="ts">
import { NavBar, showSuccessToast ,showFailToast} from "vant";

import { ref } from 'vue';

import { useRouter } from 'vue-router'

const router = useRouter()

const onClickLeft = () => router.push('/home');

const del = () => {
    localStorage.removeItem('token');
    localStorage.removeItem('userid')
    router.push('/home')
    showSuccessToast('退出成功');
}

const app = () => {
    const token = localStorage.getItem('token')
    const id = localStorage.getItem('userid')
    console.log(id);
    console.log(token);
    if (id == null || id == null) {
        router.push('/home')
        showFailToast('请先登录')
    }
}
app()

</script>

<style scoped>
button {
    margin-top: 20px;
}
</style>